using System;
using System.Collections.Generic;
using System.Text;

namespace AIFSContentManagementSystem.DomainObjects
{
    public class DefaultCriterionExpressionFactory : ICriterionExpressionFactory
    {
        public CriterionExpression CreateInstance(string DataType)
        {
            if (string.IsNullOrEmpty(DataType))
                throw new ArgumentNullException("DataType is required to create the Criterion");

            CriterionExpression expression = null;
            switch (DataType.ToUpper().Trim())
            {
                case "STRING":
                    expression = new StringCriterionExpression();
                    break;
                case "NUMERIC":
                    expression = new NumericCriterionExpression();
                    break;
                case "DATE":
                    expression = new DateCriterionExpression();
                    break;
                case "BOOLEAN":
                    expression = new BooleanCriterionExpression();
                    break;
            }

            if (expression == null)
                throw new NotSupportedException(string.Format("CriterionExpression of type {0} is not supported", DataType));

            return expression;
        }
    }
}
